package com.androidx.p013lv.invention.view;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.alibaba.android.arouter.launcher.ARouter;
import com.androidx.p013lv.base.Constance;
import com.androidx.p013lv.base.bean.InventionBean;
import com.androidx.p013lv.base.bean.VideoBean;
import com.androidx.p013lv.base.glide.GlideUtils;
import com.androidx.p013lv.base.interfaces.Key;
import com.androidx.p013lv.base.listener.ItemClickListener;
import com.androidx.p013lv.base.p015ui.LazyFragment;
import com.androidx.p013lv.base.utils.TimeUtils;
import com.androidx.p013lv.base.utils.UiUtils;
import com.androidx.p013lv.invention.C1069R;
import com.androidx.p013lv.invention.OnInventionType;
import com.androidx.p013lv.invention.adapter.AdapterTwenty;

/* renamed from: com.androidx.lv.invention.view.TwentyView */
public class TwentyView {
    AdapterTwenty adapter;
    LinearLayout btn_more;
    LinearLayout btn_swap;
    String domain;
    Fragment fragment;
    InventionBean inventionBean;
    ImageView iv_cover;
    ImageView iv_original;
    ImageView iv_pay;
    ImageView iv_vip;
    LinearLayout ll_main;
    Context mContext;
    OnInventionType onInventionType;
    int position;
    RecyclerView recycler;
    RelativeLayout rl_content;
    TextView tv_play_sum;
    TextView tv_time;
    TextView tv_title;

    public TwentyView(View view, Fragment fragment2, String str, OnInventionType onInventionType2) {
        this.mContext = view.getContext();
        this.onInventionType = onInventionType2;
        this.domain = str;
        this.fragment = fragment2;
        this.tv_title = (TextView) view.findViewById(C1069R.C1072id.tv_title);
        this.recycler = (RecyclerView) view.findViewById(C1069R.C1072id.recycler);
        this.btn_more = (LinearLayout) view.findViewById(C1069R.C1072id.btn_more);
        this.iv_cover = (ImageView) view.findViewById(C1069R.C1072id.iv_cover);
        this.tv_play_sum = (TextView) view.findViewById(C1069R.C1072id.tv_play_sum);
        this.iv_pay = (ImageView) view.findViewById(C1069R.C1072id.iv_pay);
        this.iv_vip = (ImageView) view.findViewById(C1069R.C1072id.iv_vip);
        this.iv_original = (ImageView) view.findViewById(C1069R.C1072id.iv_original);
        this.tv_time = (TextView) view.findViewById(C1069R.C1072id.tv_time);
        this.ll_main = (LinearLayout) view.findViewById(C1069R.C1072id.ll_main);
        this.rl_content = (RelativeLayout) view.findViewById(C1069R.C1072id.rl_content);
        ViewGroup.LayoutParams layoutParams = this.rl_content.getLayoutParams();
        layoutParams.height = (int) ((double) (((UiUtils.getWindowWidth() - UiUtils.dp2px(12)) * 190) / 406));
        this.rl_content.setLayoutParams(layoutParams);
    }

    public void setView(InventionBean inventionBean2, int i) {
        this.inventionBean = inventionBean2;
        this.position = i;
        this.tv_title.setText(inventionBean2.getStationName());
        this.btn_more.setOnClickListener(new View.OnClickListener() {
            /* class com.androidx.p013lv.invention.view.TwentyView.View$OnClickListenerC11931 */

            public void onClick(View view) {
                TwentyView.this.onInventionType.onClick(TwentyView.this.inventionBean, TwentyView.this.position, view.getId());
            }
        });
        if (this.inventionBean.getVideoList() == null || this.inventionBean.getVideoList().size() <= 0 || this.inventionBean.getVideoList().get(0) == null) {
            this.ll_main.setVisibility(8);
        } else {
            this.ll_main.setVisibility(0);
            VideoBean videoBean = this.inventionBean.getVideoList().get(0);
            if (this.inventionBean.getCoverImg() == null || TextUtils.isEmpty(this.inventionBean.getCoverImg())) {
                this.iv_cover.setImageResource(C1069R.C1071drawable.base_ic_default_cover);
            } else {
                Fragment fragment2 = this.fragment;
                if (fragment2 == null) {
                    GlideUtils.loadCropRadiusWh2(this.domain + this.inventionBean.getCoverImg(), 4, this.iv_cover, 600);
                } else {
                    GlideUtils.loadCropRadiusWh2(fragment2, this.domain + this.inventionBean.getCoverImg(), 4, this.iv_cover, 600);
                }
            }
            this.tv_time.setText(TimeUtils.stringForTime(videoBean.getPlayTime() * 1000));
            this.iv_vip.setVisibility(8);
            this.iv_pay.setVisibility(8);
            if (videoBean.getVideoType() == 1) {
                this.iv_vip.setVisibility(0);
            } else if (videoBean.getVideoType() == 2) {
                this.iv_pay.setVisibility(0);
            }
            if (videoBean.isSelfMade()) {
                this.iv_original.setVisibility(0);
            } else {
                this.iv_original.setVisibility(8);
            }
            this.iv_cover.setOnClickListener(new View.OnClickListener() {
                /* class com.androidx.p013lv.invention.view.TwentyView.View$OnClickListenerC11942 */

                public void onClick(View view) {
                    ARouter.getInstance().build(Constance.ONE_ACTIVITY).withString(Key.TXT, TwentyView.this.inventionBean.getStationName()).withInt("type", TwentyView.this.inventionBean.getStationId()).navigation();
                }
            });
        }
        setRecycler();
    }

    /* access modifiers changed from: package-private */
    public void setRecycler() {
        this.recycler.setLayoutManager(new LinearLayoutManager(this.fragment.getContext(), 0, false));
        AdapterTwenty adapterTwenty = new AdapterTwenty(this.fragment, this.inventionBean.getVideoList());
        this.adapter = adapterTwenty;
        adapterTwenty.setDomain(this.domain);
        this.recycler.setAdapter(this.adapter);
        this.adapter.setItemListener(new ItemClickListener() {
            /* class com.androidx.p013lv.invention.view.TwentyView.C11953 */

            @Override // com.androidx.p013lv.base.listener.ItemClickListener
            public void onItemClick(View view, int i) {
                ((LazyFragment) TwentyView.this.fragment).startVideoPlay(((VideoBean) TwentyView.this.adapter.getDataInPosition(i)).getVideoId());
            }
        });
    }
}
